;(function() {
		init_parsley();
	   	$("#form-submit").click(function(){
	   		var flag=$('#validate-form').parsley('validate' );
	   		
			if(is_auto_read()){
					return false;
			}
			
	   		var csharp=window.external;
	   		var pvalue=$("#pvalue").val();
			var num=csharp.WriteAuth(pvalue);		
			if(num<0){//写卡错误(写取权限)
				toastr['error'](csharp.GetError(num)+","+num);
				return false;
			}
			
			var num1=csharp.ReadCard();
			if(num1<0){//读卡号(读卡号)
				toastr['error'](csharp.GetError(num1)+","+num1);
				return false;
			}else{
				$("#card_no").val(num1);
			}
			
	   		if(flag){
	   			$.post(
	   				"/admin/SlidingGroup/give_post",
	   				$("#validate-form").serialize(),
	   				function(data){
			      		if(data.flag){
			      			$("#myModal").modal("hide");
			      			toastr['success']("操作成功！", ''); 
			      			$("#myform #btn-advanced-refresh").trigger("click");// 刷新页面
			      		}else{
			      		 	toastr['error'](data.msg,"操作失败！"); 
			      		}
	   				}
	   			);
	   		}
	   	})
})();